﻿// Author: AustralTek 
// Create date: 2010/05/04
// http://www.australtek.com
// Copyright: 2009 - 2010

(function () {
    function _IndustrialSlickGrid(object, options) {
        var grid;

        var privateParameters = null;
        var data = null;

        var actualRowID = null;
        var beingModified = false;
        var defaultNewRow;
        var IDColumn = null; //(Array) Contains number of the column, its dataType and its name
        var rows;

        var loadingContainer;
        var loadingImage;
        var loadingTitle;

        var contextMenu;

        var originalProcedure = null;

        var rowsArray = new Array(); //Data of the grid

        var ddpColumns = new Array(); //Column with ddp properties
        var ddpDataList;

        //        function _getElementSizeWidth(elem) {
        //            try {
        //                if (elem) {
        //                    if (elem.offsetWidth != undefined) return elem.offsetWidth;
        //                    else if (elem.clientWidth != undefined) return elem.clientWidth;
        //                    else if (elem.parentElement) return _getParentSize(elem.parentElement);
        //                }
        //                else if (window.document.body.clientWidth != undefined) return window.document.body.clientWidth;
        //                else if (window.document.body.offsetWidth != undefined) return window.document.body.offsetWidth;
        //                else return defaultWidth;
        //            } catch (Error) { privateParameters.Events.onError(Error); }
        //        };

        function _initialize(myDiv, options) {
            try {
                /* ************************************************************* */

                var slickPropertiesArray = [];
                var slickGridAttributes = [];

                if ((options != null) && (options['Attributes'] != undefined)) slickGridAttributes = options['Attributes'];
                for (var key in options) if (key != 'Attributes') slickPropertiesArray[key] = options[key]; //Separates IndustrialSlickGrid options from ID widget options
                slickPropertiesArray.slickAttributes = slickGridAttributes;
                privateParameters = new PrivateParameters(slickPropertiesArray);
                originalProcedure = privateParameters.DatabaseParameters.Procedure;
                if (myDiv == null) return;
                //var _tWdith = _getElementSizeWidth(myDiv);
                var uxISGContainer = document.createElement('div');
                uxISGContainer.className = 'IndustrialSlickGridContainer';
                var uxISGHeader = document.createElement('div');
                uxISGHeader.className = 'ISGHeader';
                var uxISGP = document.createElement('div');
                uxISGP.className = 'classTitle';
                uxISGP.innerHTML = (options.Title) ? 'Industrial SlickGrid 2.0 [' + options.Title + ']' : 'Industrial SlickGrid 2.0';
                uxISGHeader.appendChild(uxISGP);
                uxISGContainer.appendChild(uxISGHeader);
                var uxISGTableContainer = document.createElement('div');
                uxISGTableContainer.className = 'ISGTableContainer';
                uxISGTableContainer.id = 'pISGTableContainer';
                uxISGTableContainer.style.textAlign = 'left';
                uxISGContainer.appendChild(uxISGTableContainer);

                if (options.Attributes.showIDColumn == undefined) options.Attributes.showIDColumn = false; //Default value
                privateParameters = new PrivateParameters(options);
                privateParameters.Version.Class = 'IndustrialSlickGrid';
                privateParameters.Container = uxISGTableContainer;

                var uxLoadingContainer = document.createElement('div');
                loadingContainer = uxLoadingContainer;
                uxLoadingContainer.className = 'loadingContainer';
                uxLoadingContainer.style.display = 'none';
                uxISGHeader.appendChild(uxLoadingContainer);

                var uxLoadingImage = document.createElement('div');
                uxLoadingImage.className = 'animate';
                loadingImage = uxLoadingImage;
                uxLoadingContainer.appendChild(uxLoadingImage);

                var uxLoadingTitle = document.createElement('div');
                uxLoadingTitle.className = 'title';
                loadingTitle = uxLoadingTitle;
                uxLoadingContainer.appendChild(uxLoadingTitle);
                uxLoadingTitle.innerHTML = 'Loading...';

                myDiv.appendChild(uxISGContainer);
                /* ************************************************************* */

                //Builds context menu for delete or copy
                if (privateParameters.Attributes.AllowDelete != undefined || privateParameters.Attributes.AllowCopy != undefined ||
                (privateParameters.Attributes.AllowDelete) || privateParameters.Attributes.AllowCopy) {
                    var title = document.createElement('b');
                    title.innerHTML = 'Options';
                    contextMenu = document.createElement('ul');
                    contextMenu.id = 'contextMenu';
                    contextMenu.className = 'uxContextMenu';
                    contextMenu.style.display = 'none';
                    contextMenu.style.position = 'absolute';
                    contextMenu.appendChild(title);
                    if (privateParameters.Attributes.AllowDelete) {
                        var li = document.createElement('li'); li.data = 'Delete'; li.innerHTML = 'Delete';
                        contextMenu.appendChild(li);
                    }
                    if (privateParameters.Attributes.AllowCopy) {
                        var li = document.createElement('li'); li.data = 'Copy'; li.innerHTML = 'Copy';
                        contextMenu.appendChild(li);
                    }
                    document.getElementsByTagName('body')[0].appendChild(contextMenu);
                }

            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _CRUD(operation, parameters) {
            try {
                loadingImage.className = 'animate';
                loadingTitle.innerHTML = 'Loading...';
                loadingContainer.style.display = '';

                if (parameters == null) //Empties parameters
                    parameters = new QueryParameters();

                if (operation == 'Delete' || operation == 'Copy') {
                    var selectedRow = grid.getSelectedRows()[0];
                    var idToDelete = rowsArray[selectedRow][IDColumn.name];
                    parameters = new QueryParameters();
                    parameters.Add(IDColumn.name, IDColumn.type, idToDelete);
                }

                var url = privateParameters.URL;
                var options = {}; options.data = {};
                options.data.DatabaseParameters = privateParameters.DatabaseParameters;

                options.data.JSONFile = privateParameters.JSONFile;
                for (var conParam in privateParameters.ConnectionParameters)
                    options[conParam] = privateParameters.ConnectionParameters[conParam];
                if ((parameters) && (parameters.Version))
                    options.data.DatabaseParameters.QueryParameters = parameters.GetQueryParameters();
                else options = (parameters) ? parameters : options;

                if (operation.indexOf('ddpData') > -1) {
                    privateParameters.DatabaseParameters.Procedure = operation.substring(8);
                    operation = 'ddpData';
                } else {
                    if (operation == 'Refresh') {
                        privateParameters.DatabaseParameters.Procedure = originalProcedure;
                    } else {
                        privateParameters.DatabaseParameters.Procedure = originalProcedure.substring(0, (originalProcedure.length - 1)) + operation; //Procedure change for different purposes
                    }
                }
                if (operation == 'Create' || operation == 'Copy' || operation == 'ddpData') options.async = false;

                options.data.Namespace = privateParameters.Version.Namespace;
                options.data.Class = privateParameters.Version.Class;

                options.onSuccess = function (requestData) {
                    if (operation == 'Delete') {
                        //Remove the row to delete from rowsArray
                        rowsArray.splice(selectedRow, 1);
                        grid.setData(rowsArray, false);
                        grid.updateRowCount();
                        grid.render();
                    }
                    if (requestData) { //Database information recieved
                        if (operation == 'Create' || operation == 'Copy') {
                            defaultNewRow = requestData;
                        }
                        if (operation == 'Refresh') { //Refresh
                            data = requestData;
                            _redraw(privateParameters.Container, data);
                            if (ddpColumns.length != 0)
                                _refreshDDPColumns();
                        }
                        if (operation == 'ddpData')
                            ddpDataList = requestData;
                    }
                    if (requestData == null && operation == 'Refresh') { //If refresh is done and no data received
                        loadingContainer.style.display = '';
                        loadingTitle.innerHTML = 'No available Data.';
                        loadingImage.className = 'noAnimate';
                    } else
                        loadingContainer.style.display = 'none';
                }
                options.onFailure = function (message) {
                    loadingContainer.style.display = '';
                    loadingTitle.innerHTML = 'No available Data.';
                    loadingImage.className = 'noAnimate';
                    //privateParameters.Events.onFailure(message);
                }
                RequestJSON(privateParameters.URL, options);

            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _redraw(container, data) {
            try {
                var opt = privateParameters.Attributes;
                var UpdateSQLParams = new QueryParameters();

                //Build columns
                var columnsArray = new Array();
                for (var i = 0; i < data.columns; i++) { //All columns                   
                    var eachColumn = new Object();
                    var headerNameSplit = data.matrix[i].split('!');
                    var headerName = headerNameSplit[0]; //The header name without header options    
                    eachColumn.dataFormat = data.dataTypesArray[i];

                    eachColumn.name = headerName;
                    if (headerNameSplit[1] != undefined) {
                        //Column properties                          
                        for (var j = 1; j < headerNameSplit.length; j++) {
                            var property = headerNameSplit[j].toLowerCase();
                            if (property.indexOf('wd') > -1) eachColumn.width = parseFloat(property.substring(property.indexOf(':') + 1, property.length));
                            if (property == 'tc') eachColumn.cssClass = 'titleColumn'; //Set as title
                            if (property == 'ac') eachColumn.cssClass = 'alignCenter'; //Align center
                            if (property == 'al') eachColumn.cssClass = 'alignLeft'; //Align left
                            if (property == 'ar') eachColumn.cssClass = 'alignRight'; //Align right                              
                            if (property == 'so') eachColumn.sortable = true; //The column can be sorted                            
                            if (property.indexOf('{') > -1) { //The column header contains a JSON
                                var property = JSONDecode(property);
                                if (property.type == 'ddp') {
                                    _CRUD('ddpData/' + property.data, null); //Gets ddp data from database

                                    eachColumn.ddpData = ddpDataList;
                                    eachColumn.editor = DDPEditor;
                                    eachColumn.dataFormat = 'int';

                                    var aux = new Array();
                                    var itemWidth = 0;
                                    if (ddpDataList) {
                                        for (var u = ddpDataList.columns; u < ddpDataList.matrix.length; u += ddpDataList.columns) {
                                            var kvp = {}; //keyValuePair
                                            kvp.key = ddpDataList.matrix[u];
                                            kvp.value = ddpDataList.matrix[u + 1];
                                            aux.push(kvp);
                                            if (kvp.key.visualLength() > itemWidth) //Measures the max width of ddp
                                                itemWidth = kvp.key.visualLength();
                                        }
                                    }

                                    //Add new ddpColumnData
                                    var ddpColumn = new Object();
                                    ddpColumn.name = headerName;
                                    ddpColumn.data = aux;
                                    ddpColumns.push(ddpColumn);
                                    eachColumn.width = itemWidth + 50;
                                }
                            }
                            if (property == 'id') {
                                eachColumn.dataFormat = data.dataTypesArray[i];
                                eachColumn.unselectable = true;
                                eachColumn.cssClass = 'idColumn';
                                eachColumn.name = headerNameSplit[0];
                                eachColumn.editor = IntegerCellEditor;

                                IDColumn = new Object();
                                IDColumn.name = headerName;
                                IDColumn.number = i;
                                IDColumn.type = eachColumn.dataFormat;
                            }
                            if (property == 'rq') eachColumn.validator = _requiredFieldValidator; //Required field                          
                            if (property == 'pc') { //Percentage column
                                eachColumn.resizable = false;
                                eachColumn.formatter = GraphicalPercentCompleteCellFormatter;
                                eachColumn.editor = TextCellEditor;
                                //eachColumn.editor = PercentCompleteCellEditor;
                                eachColumn.dataFormat = 'int';
                            }
                        }
                    }

                    eachColumn.field = headerName;
                    eachColumn.id = headerName;
                    eachColumn.resizable = true;

                    if (data.matrix[i + data.columns] != undefined && data.matrix[i + data.columns] != null) //If received data contains rows
                        var cellValue = data.matrix[i + data.columns].toUpperCase();

                    //Formats data of cells                    
                    if (eachColumn.editor != PercentCompleteCellEditor && eachColumn.editor != DDPEditor) { //If it's a percentage cell
                        if (eachColumn.dataFormat == 'bit') { //If it's a boolean cell
                            eachColumn.width = 80;
                            eachColumn.cssClass = 'alignCenter';
                            eachColumn.editor = YesNoCheckboxCellEditor;
                            eachColumn.formatter = BoolCellFormatter;
                        } else {
                            if (eachColumn.dataFormat == 'datetime') { //If it's a date cell
                                eachColumn.editor = DateCellEditor;
                            } else {
                                if (eachColumn.dataFormat == 'int') {
                                    eachColumn.editor = IntegerCellEditor;
                                } else {
                                    if (eachColumn.dataFormat == 'float')
                                        eachColumn.editor = DecimalCellEditor;
                                    else {
                                        eachColumn.editor = TextCellEditor; //Default editor is for strings                                        
                                    }
                                }
                            }
                        }
                    }

                    columnsArray.push(eachColumn);
                }

                xmlParam = null;

                if (privateParameters.Attributes.XMLUpdate != undefined && privateParameters.Attributes.XMLUpdate == true) { //If xml params needed
                    xmlParam = new XMLWriter();
                    xmlParam.BeginNode('ROOT');
                }

                $(function () {
                    rows = Math.round(data.matrix.length / data.columns);
                    if (IDColumn == null) rows = 2; //Set an aux blank row

                    var k = data.columns;
                    //Add rows
                    for (var i = 0; i < rows - 1; i++) {
                        var eachRow = new Object();
                        for (var j = 0; j < data.columns; j++) {
                            var cellValue = data.matrix[k].toUpperCase();
                            //Rows formatting
                            if (columnsArray[j].dataFormat == 'datetime')
                                eachRow[columnsArray[j].field] = _formatDate(cellValue);
                            else {
                                if (cellValue == 'TRUE') {
                                    eachRow[columnsArray[j].field] = true;
                                } else {
                                    if (cellValue == 'FALSE')
                                        eachRow[columnsArray[j].field] = false;
                                    else
                                        eachRow[columnsArray[j].field] = data.matrix[k];
                                }
                            }
                            k++;
                        }
                        rowsArray.push(eachRow);
                    }

                    // Initialize the grid
                    grid = new Slick.Grid($('#' + container.id), rowsArray, columnsArray, opt);

                    if (IDColumn != null) { //If no ID column was found, the table cannot be edited from the database                        
                        // Hide ID columns
                        if (!(privateParameters.Attributes.showIDColumn)) {
                            var column = {};
                            column.id = IDColumn.name;
                            grid.setColumnVisibility(column, false);
                        }

                        grid.onBeforeEditCell = function (row, cell, dataContext) {
                            if (actualRowID != null && beingModified) {
                                if (dataContext == undefined || actualRowID != dataContext[IDColumn.name]) { //The user jumped from that row                                
                                    if (privateParameters.Attributes.XMLUpdate != undefined && (privateParameters.Attributes.XMLUpdate)) { //If xml params needed
                                        xmlParam.Node(IDColumn.name, actualRowID);
                                        xmlParam.EndNode();
                                        xmlParam.Close();
                                        UpdateSQLParams.Add('XML', 'xml', xmlParam.ToString());
                                    } else {
                                        UpdateSQLParams.Add(IDColumn.name, IDColumn.type, actualRowID);
                                    }

                                    _CRUD('Update', UpdateSQLParams);
                                    actualRowID = null;
                                    beingModified = false;
                                    UpdateSQLParams = new QueryParameters();
                                    if (xmlParam != null) {
                                        xmlParam = new XMLWriter();
                                        xmlParam.BeginNode('ROOT');
                                    }

                                    if (ddpColumns.length != 0)
                                        _refreshDDPColumns();
                                }
                            }
                            if (ddpColumns.length != 0)
                                _refreshDDPColumns();
                        }

                        grid.onCellChange = function (row, cell, dataContext) {
                            var key = 0;

                            if (actualRowID == null) {//First selected cell
                                actualRowID = dataContext[IDColumn.name];
                                beingModified = true;
                                loadingImage.className = 'animate';
                                loadingTitle.innerHTML = 'Editing row...';
                                loadingContainer.style.display = '';
                            }

                            for (var propName in dataContext) { //Add ConnectionParameters for the update
                                if (key == cell) {
                                    if (privateParameters.Attributes.XMLUpdate != undefined && (privateParameters.Attributes.XMLUpdate)) //If xml params needed
                                        xmlParam.Node(columnsArray[key].name, dataContext[propName].toString());
                                    else
                                        UpdateSQLParams.Add(columnsArray[key].name, columnsArray[key].dataFormat, dataContext[propName]); //Normal sql params
                                }
                                key++;
                            }
                        }

                        grid.onAddNewRow = function (cellInfo, value) {
                            _CRUD('Create', null);
                            var item = defaultNewRow;
                            if (item != undefined) {
                                var newItem = new Array();

                                for (var i = 0; i < item.columns; i++) { //Gets data from the new default register                                    
                                    var property = item.matrix[i + item.columns];
                                    if (property.toUpperCase() == "TRUE")
                                        newItem[item.matrix[i]] = true;
                                    else
                                        if (property.toUpperCase() == "FALSE")
                                            newItem[item.matrix[i]] = false;
                                        else
                                            newItem[item.matrix[i]] = property;
                                }

                                var CreationSQLParams = new QueryParameters();

                                if (privateParameters.Attributes.XMLUpdate != undefined && (privateParameters.Attributes.XMLUpdate)) { //If xml params needed
                                    var xmlParam = new XMLWriter();
                                    xmlParam.BeginNode('ROOT');
                                    xmlParam.Node(cellInfo.name, value.toString());
                                    xmlParam.Node(IDColumn.name, newItem[IDColumn.name]);
                                    xmlParam.EndNode();
                                    xmlParam.Close();
                                    CreationSQLParams.Add('XML', 'xml', xmlParam.ToString());
                                } else {
                                    CreationSQLParams.Add(cellInfo.name, cellInfo.dataFormat, value);
                                    CreationSQLParams.Add(IDColumn.name, IDColumn.type, newItem[IDColumn.name]);
                                }

                                _CRUD('Update', CreationSQLParams);
                                actualRowID = null;
                                beingModified = false;

                                if (xmlParam != null) {
                                    xmlParam = new XMLWriter();
                                    xmlParam.BeginNode('ROOT');
                                }

                                newItem[cellInfo.field] = value;
                                rowsArray[rowsArray.length] = newItem;

                                grid.updateRowCount();
                                grid.render();
                                grid.updateRow(rowsArray.length - 1);
                                if (ddpColumns.length != 0)
                                    _refreshDDPColumns();
                            }
                        }
                        grid.onContextMenu = function (e, row, cell) {

                            if (privateParameters.Attributes.AllowDelete != undefined && (privateParameters.Attributes.AllowDelete)) {
                                grid.setSelectedRows([row]);

                                $("#contextMenu")
                                .data("row", row)
                                .css("top", e.pageY)
                                .css("left", e.pageX)
                                .fadeIn(150);
                                $("body").one("click", function () {
                                    $("#contextMenu").fadeOut(150);
                                });
                                $("body").keydown(function (event) {
                                    if (event.keyCode == '27') {
                                        $("#contextMenu").fadeOut(150);
                                    }
                                });

                                return true;
                            }
                        };
                        if (privateParameters.Attributes.AllowDelete != undefined || privateParameters.Attributes.AllowCopy != undefined)
                            if (privateParameters.Attributes.AllowDelete || (privateParameters.Attributes.AllowCopy)) {
                                $("#contextMenu").click(function (e) {
                                    if (e.target.innerHTML == 'Delete') {
                                        var row = $(this).data("row");
                                        _CRUD('Delete', null);
                                    }
                                    if (e.target.innerHTML == 'Copy') {
                                        var row = $(this).data("row");
                                        _CRUD('Copy', null);

                                        var item = defaultNewRow;
                                        if (item != undefined) {
                                            var newItem = new Array();

                                            for (var i = 0; i < item.columns; i++) { //Gets data from the new default register
                                                var property = item.matrix[i + item.columns];
                                                if (property.toUpperCase() == "TRUE")
                                                    newItem[item.matrix[i]] = true;
                                                else
                                                    if (property.toUpperCase() == "FALSE")
                                                        newItem[item.matrix[i]] = false;
                                                    else
                                                        newItem[item.matrix[i]] = property;
                                            }
                                            rowsArray[rowsArray.length] = newItem;

                                            grid.updateRowCount();
                                            grid.render();
                                            grid.updateRow(rowsArray.length - 1);
                                            if (ddpColumns.length != 0)
                                                _refreshDDPColumns();
                                        }
                                    }
                                });
                            }
                    } else {
                        grid.onBeforeEditCell = function (row, cell, dataContext) {
                            if (ddpColumns.length != 0) {
                                _refreshDDPColumns();
                            }
                        }
//                        grid.onCellChange = function (row, cell, dataContext) {
//                            if (ddpColumns.length != 0) {
//                                _refreshDDPColumns();
//                            }
//                        }
                    }
                })

            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _refreshDDPColumns(row, columnName) {
            try {
                for (var p = 0; p < ddpColumns.length; p++) { //For each ddpColumn, refresh its contents to show the string
                    for (var j = 0; j < rowsArray.length; j++) {
                        var value = rowsArray[j][ddpColumns[p].name];
                        for (var k = 0; k < ddpColumns[p].data.length; k++) {
                            if (value != undefined && ddpColumns[p].data[k].value == value)
                                rowsArray[j][ddpColumns[p].name] = ddpColumns[p].data[k].key;
                        }
                    }
                }
                grid.setData(rowsArray);
                grid.render();
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _getDDPColumnElement(column, key) {
            try {
                for (var h = 0; h < ddpColumns.length; h++) {
                    if (ddpColumns[h].name == column) {
                        for (var i = 0; i < ddpColumns[h].data.length; i++) {
                            if (ddpColumns[h].data[i].key == key)
                                return ddpColumns[h].data[i].value;
                        }
                    }
                }
            } catch (Error) { privateParameters.Events.onError(Error); }
        }

        function _setEditable(bool) {
            try {
                if (bool) {
                    privateParameters.Attributes.editable = true;
                    privateParameters.Attributes.enableCellNavigation = true;
                    privateParameters.Attributes.autoEdit = true;
                    privateParameters.Attributes.enableAddRow = true;
                } else {
                    privateParameters.Attributes.editable = false;
                    privateParameters.Attributes.enableCellNavigation = false;
                    privateParameters.Attributes.autoEdit = false;
                    privateParameters.Attributes.enableAddRow = false;
                }
                grid.setOptions(privateParameters.Attributes);
                grid.updateRowCount();
                grid.render();
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _formatDate(strDate) {
            try {
                var newDate = new Date(strDate);
                if (!(isNaN(newDate))) {
                    var m, d, y;
                    m = newDate.getMonth() + 1; if (m < 10) m = '0' + m;
                    d = newDate.getDate(); if (d < 10) d = '0' + d;
                    var retDate = m + '/' + d + '/' + newDate.getFullYear();
                    return retDate;
                } else
                    return '06/02/1978'; //Default date if not found
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _isNumeric(sText) {
            try {
                if (sText == "") return false;
                var ValidChars = "0123456789.,";
                var IsNumber = true;
                var Char;

                for (i = 0; i < sText.length && IsNumber == true; i++) {
                    Char = sText.charAt(i);
                    if (ValidChars.indexOf(Char) == -1) {
                        IsNumber = false;
                    }
                }
                return IsNumber;
            } catch (Error) { return false; }
        };

        function _requiredFieldValidator(value) {
            try {
                if (value == null || value == undefined || !value.length)
                    return { valid: false, msg: "This is a required field" };
                else
                    return { valid: true, msg: null };
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        function _getRowData(row) {
            try {
                return rowsArray[row];
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        String.prototype.visualLength = function () {
            var ruler = document.createElement('span');
            ruler.id = 'ruler'; ruler.style.visibility = 'hidden'; ruler.style.whiteSpace = 'nowrap'; ruler.style.position = 'absolute';
            ruler.style.width = 'auto';
            ruler.innerHTML = this;
            document.getElementsByTagName('body')[0].appendChild(ruler);
            return ruler.offsetWidth;
        };

        _initialize(object, options);

        //Public methods
        this.RefreshData = function (parameters) {
            try {
                _CRUD('Refresh', parameters);
            } catch (Error) { return Error; }
        };

        this.DeleteSelectedRow = function () {
            try {
                _CRUD('Delete', null);
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        this.CreateNewRow = function () {
            try {
                _CRUD('Create', null);
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        this.GetRowData = function (row) {
            try {
                return _getRowData(row);
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        this.GetDDPColumnElement = function (column, key) {
            try {
                return _getDDPColumnElement(column, key);
            } catch (Error) { privateParameters.Events.onError(Error); }
        };

        this.SetEditable = function (bool) {
            _setEditable(bool);
        };

    }
    window.IndustrialSlickGrid = function (object, options) { return new _IndustrialSlickGrid(object, options); }
})();